<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/26 0026
 * Time: 下午 5:18
 */
namespace app\common\model;


class Distributionrecord extends BaseModel {
    const status_1 = 1; //订单状态(待接单＝1
    const status_2 = 2; // 待取货＝2
    const status_3 = 3; // 配送中＝3
    const status_4 = 4; // 已完成＝4
    const status_5 = 5; // 已取消＝5
    const status_7 = 7; // 已过期=7
    const status_8 = 8; // 指派单=8
    const status_9 = 9; // 妥投异常之物品返回中=9
    const status_10 = 10; // 妥投异常之物品返回完成=10
    const status_1000 = 1000; // 创建达达运单失败=1000

    //根据当前订单id和当前订单状态，查询该订单数据是否存在
    public function findDistributionRecord($param){
        return self::where($param)->find();

    }

    /**
     *
     */
    public function findDistributionRecords($order_id){
        return self::where("order_id","=",$order_id)->order("statusCode","ASC")->select();
    }

    //如果存在就修改该订单
    public function updateDistributionRecord($data,$id){
        return self::where("id","=",$id)->update($data);
    }

    //不存在就保存当前订单
    public function insertDistributionRecord($param){
        $id = get_uniqid_id();
        $param['id']=$id;
      return  self::insert($param);
    }


}